//Deleting Models
To delete a model, you may call the delete method on the model instance:
use App\Models\Flight;
$flight = Flight::find(1);
$flight->delete();
//You may call the truncate method to delete all of the model's associated database records. The truncate operation will also reset any auto-incrementing IDs on the model's associated table:
Flight::truncate();
//Deleting An Existing Model By Its Primary Key
Flight::destroy(1);
Flight::destroy(1, 2, 3);
Flight::destroy([1, 2, 3]);
Flight::destroy(collect([1, 2, 3]));
//Deleting Models Using Queries
$deleted = Flight::where('active', 0)->delete();
use App\Models\Flight;
$flight = Flight::find(1);
$flight->delete();
// If there's a flight from Oakland to San Diego, set the price to $99.
// If no matching model exists, create one.
$flight = App\Models\Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);